package com.bdqn.dao;

import bean.User;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;

@Repository
@Mapper
public interface UserDao {
    @Select("select * from t_member where mobile=#{moblie}")
    User find(@Param("moblie") String moblie);

    @Select("select * from t_member where mobile=#{moblie} And password=#{password}")
    User Login_find(@Param("moblie")String moblie,@Param("password")String password);

    //校验账号是否被注册
    @Select("select code from t_member where mobile = #{phone} ")
    Integer phone(@Param("phone")String phone);

    //校验邮箱是否是该手机号
    @Select("select email from t_member where mobile = #{phone}")
    String QueryeEail (String phone);
    //校验邀请码
    @Select("select code from t_member where code = #{Invitation} ")
    public String invitationcode (@Param("Invitation")String Invitation);

    //注册
    //验证码就是当前账号的邀请码
    @Insert("insert into t_member (mobile,password,code,email) values(#{moblie},#{password},#{Code},#{email})")
    public void register(@Param("moblie")String moblie,@Param("password")String password,@Param("Code")String Code,@Param("email")String email);

    //忘记密码（修改密码）
    @Update("UPDATE t_member SET PASSWORD = #{updatepassword} WHERE mobile = #{phone}")
    Integer forget(String updatepassword,String phone);


    //检查有没有该邮箱
    @Select("SELECT * FROM t_member WHERE email=#{email}")
    Integer Email(String email);


}
